# Harris 1971 Television Survey, study no. 2135

## packages 
require("dplyr")
require("readstata13")

## set working directory to replication repository


## download data
survey <- read.dta13("Harris_Data/Harris 1971 Television Survey, study no. 2135/harris_s2135_spss.dta")

## pid
survey$pid <- c(1:nrow(survey))
class(survey$pid)

## study number
survey$study <- "2135"
class(survey$study)

## year
survey$year <- 1971
class(survey$year)

## geographpic data
survey$urban <- as.character(survey$S13)
table(survey$urban)

## region 
survey$region <- as.character(survey$S11)
table(survey$region)

## respondent head of house
table(survey$F1A)
survey$hh <- as.character(survey$F1A)

## inequality increasing
table(survey$Q30_A)
survey$inequality <- as.character(survey$Q30_A)
table(survey$inequality)

## inequality variable version
survey$inequality.variable <- 1
class(survey$inequality.variable)

## union 
survey$union.self <- as.character(survey$F4_1)
survey$union.other <- as.character(survey$F4_2)
table(survey$union.other)

## employed
table(survey$F3A)
survey$employed <- as.character(survey$F3A)
class(survey$employed)

# empl self
survey$employed.self <- NA

## Occupation
table(survey$F3B)
survey$occupation <- as.character(survey$F3B)
class(survey$occupation)

# occ self
survey$occupation.self<- NA

## household size
survey$hhsize <- NA

## Education
table(survey$Q33)
survey$educ <- as.character(survey$Q33)
table(survey$educ)


## Income
table(survey$F9)
survey$income <- as.character(survey$F9)
table(survey$income)
class(survey$income)

## Age 
table(survey$F8)
survey$age <- as.character(survey$F8)
table(survey$age)

## race
table(survey$F10)
survey$race <- as.character(survey$F10)
table(survey$race)

## politics 
survey$party <- NA

## ideology
table(survey$F2)
survey$ideology <- as.character(survey$F2)
table(survey$ideology)

## gender
table(survey$F11)
survey$gender <- as.character(survey$F11)
table(survey$gender)

## religion
survey$religion <- as.character(survey$F7)
table(survey$religion)

#factuals
survey$factual1 <- NA
survey$factual2 <- NA
survey$factual3 <- NA

## alienation index
survey$dontcare <- as.character(survey$Q30_B)
survey$dontcount <- NA
survey$leftout <- NA

## question place
survey$question_place <- "no party question"

# subset
survey_2135 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
                         "inequality", "inequality.variable", "union.self", "union.other",
                         "employed", "employed.self", "occupation", "occupation.self", "hhsize", "educ", "income", 
                         "age", "race", "party", "ideology", "gender", "religion",
                         "factual1", "factual2", "factual3", "dontcare", "dontcount", "leftout",
                         "question_place")]


## save dataset in folder 
#saveRDS(survey_2135, file = "Harris_Data/survey_2135.rds")



